package com.zzj.ecology.common.enums;

/**
 * @ClassName LoginResultEnum
 * @Description 用户登录 状态枚举类
 * @Author zhijun zeng at 2020/2/29
 * @Version 1.0
 **/
public enum LoginResultEnum {

    UNKNOWN_FAILURE("9999","未知错误"),

    /* 权限 */
    USER_PERMISSION_FAILURE("4000", "请提升用户权限"),
    /* 验证码错误 */
    USER_VERIFY_ERROR("1000","验证码错误"),
    /* 用户错误 */
    USER_LOGOUT_SUCCESS("3000","用户成功登出"),
    USER_LOGIN_SUCCESS("2000","用户成功登录"),
    USER_NOT_LOGIN("2001", "用户未登录"),
    USER_ACCOUNT_EXPIRED("2002", "账号已过期"),
    USER_CREDENTIALS_ERROR("2003", "密码错误"),
    USER_CREDENTIALS_EXPIRED("2004", "密码过期"),
    USER_ACCOUNT_DISABLE("2005", "账号不可用"),
    USER_ACCOUNT_LOCKED("2006", "账号被锁定"),
    USER_ACCOUNT_NOT_EXIST("2007", "账号不存在"),
    USER_ACCOUNT_ALREADY_EXIST("2008", "账号已存在"),
    USER_ACCOUNT_USE_BY_OTHERS("2009", "账号下线")
    ;

    private String code;
    private String name;

    LoginResultEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    /**
     * 提供 code 获取 name 值
     * @param code
     * @return
     */
    public static String getNameByCode(String code) {
        for (LoginResultEnum lre : values()) {
            if (code.equals(lre.getCode())) {
                return lre.getName();
            }
        }
        return null;
    }
}
